﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="rule_form.aspx.cs" Inherits="RTGS.Web.form.rtgs.form_rtgs_rule_form" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Role Form</title>
    <link href="<%= ResolveClientUrl("~/css/jquery.validate.error.css") %>" rel="stylesheet"
        type="text/css" />
    <script src="<%= ResolveClientUrl("~/script/helper.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveClientUrl("~/script/jquery.validate.min.js") %>" type="text/javascript"></script>
    <script src="<%= ResolveClientUrl("~/script/jquery.validate.wrapper.js") %>" type="text/javascript"></script>

    <script src="<%= ResolveClientUrl("~/script/jquery.timepicker.js") %>" type="text/javascript"></script>
    <link href="<%= ResolveClientUrl("~/css/jquery.timepicker.css") %>" rel="stylesheet" type="text/css" />

    <script type="text/javascript">

        $(document).ready(function () {

            $(function () {

                $('#<%=txtRuleTime.ClientID %>').timepicker({ 'timeFormat': 'H:i:s' });
               
                $('#txtRuleCustom').timepicker({ 'timeFormat': 'H:i:s' });

            });

            $('#<%=txtRuleCode.ClientID %>').keydown(function (event) {
                // Allow: backspace, delete, tab, escape, and enter
                if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 ||
                // Allow: Ctrl+A
            (event.keyCode == 65 && event.ctrlKey === true) ||
                // Allow: home, end, left, right
            (event.keyCode >= 35 && event.keyCode <= 39)) {
                    // let it happen, don't do anything
                    return;
                }
                else {
                    // Ensure that it is a number and stop the keypress
                    if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105)) {
                        event.preventDefault();
                    }
                }
            });


            $("#save").click(function () {
                var handlerUrl = '<%= ResolveClientUrl("~/ajaxhandler/rtgs/stp_rule.ashx") %>';
                var rulecode = encodeURIComponent($('#<%=txtRuleCode.ClientID %>').val());
                var ruledesc = encodeURIComponent($('#<%=txtRuleDesc.ClientID %>').val());
                var ruletime = encodeURIComponent($('#<%=txtRuleTime.ClientID %>').val());
                var rulecustom = encodeURIComponent($('#<%=txtRuleCustom.ClientID %>').val());
                var prioritycode = encodeURIComponent($("#<%=ddlPriority.ClientID %> option:selected").val());
                


                var id = $('#<%= hfID.ClientID %>').val();

                var param = '&rulecode=' + rulecode + '&ruledesc=' + ruledesc + '&ruletime=' + ruletime + '&rulecustom=' + rulecustom + '&prioritycode=' + prioritycode;

                if (id == 0)
                    CallAjax(handlerUrl, "?method=insert&" + param);
                else
                    CallAjax(handlerUrl, "?method=update&" + param + "&id=" + id);

                parent.$('#dialog').dialog("close");
                setTimeout("parent.$('#table').trigger('reloadGrid');", 3000);
                return false;
            });
        });
    
    </script>
    <script type="text/javascript">
        function ClearText() {

            $('#txtDesc').val('');
        }

        $('#close').click(function () {
            parent.$('#dialog').dialog("close");
        });
    </script>
</head>
<body onload="ClearText();">
    <form id="form1" runat="server">
    <table border="0">
        <tr>
            <td style="width: 50">
                Rule Code
            </td>
            <td>
                :
            </td>
            <td>
               
                <asp:TextBox ID="txtRuleCode" runat="server" MaxLength="3" Width="200px"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td style="width: 50">
                Rule Desc.
            </td>
            <td>
                :
            </td>
            <td>
                <asp:TextBox MaxLength="100"  ID="txtRuleDesc" TextMode="MultiLine" runat="server" Width="300"></asp:TextBox>
            </td>
        </tr>
     <tr>
            <td style="width: 50">
                Rule Time
            </td>
            <td>
                :
            </td>
            <td>
               
               <asp:TextBox ID="txtRuleTime" runat="server" Width="100px"></asp:TextBox>
            </td>
        </tr>

         <tr>
            <td style="width: 50">
                Rule Custom Time
            </td>
            <td>
                :
            </td>
            <td>
               
               <asp:TextBox ID="txtRuleCustom" runat="server" Width="100px"></asp:TextBox>
            </td>
        </tr>
         <tr>
            <td style="width: 50">
                Rule Priority
            </td>
            <td>
                :
            </td>
            <td>
               
                <asp:DropDownList ID="ddlPriority" runat="server" Width="200px"></asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                &nbsp;
            </td>
            <td>
                <div style="text-align: right; padding-top: 10px;">
                    <a href="#" id="save" class="dialog_link ui-state-default ui-corner-all" alt="Save">
                        <span class="ui-icon ui-icon-disk"></span>Save</a> <a href="#" id="close" class="dialog_link ui-state-default ui-corner-all"
                            alt="Close" onclick="parent.$('#dialog').dialog('close');"><span class="ui-icon ui-icon-close">
                            </span>Close</a>
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                &nbsp;
            </td>
            <td>
                <asp:HiddenField ID="hfID" runat="server" />
            </td>
        </tr>
    </table>
    </form>
</body>
</html>

